package com.med.controller;

import com.med.entity.CommentsDO;
import com.med.entity.DepartmentDO;
import com.med.entity.DoctorDO;
import com.med.entity.MedicalRecordDO;
import com.med.service.ICommentsService;
import com.med.vo.CommentsVO;
import com.ruoyi.common.core.utils.PageUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import javafx.scene.control.Tab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: internet-based-healthcare
 * @BelongsPackage: com.med.controller
 * @Author: 小吴
 * @CreateTime: 2025-08-13 23:39
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RefreshScope
@RequestMapping("/comments")
public class CommentsController extends BaseController {

    @Autowired
    private ICommentsService commentsService;

    /**
     * @Description: 查询所有部门
     * @Param:
     * @return:
     */
    @RequestMapping("/queryDepartment")
    public TableDataInfo queryDepartment() {
        List<DepartmentDO> queryDepartment = commentsService.queryDepartment();
        return getDataTable(queryDepartment);
    }

    /**
     * @Description: 根据部门id查询对应的医生
     * @Param:
     * @return:
     */
    @RequestMapping("/queryDoctorByCId")
    public TableDataInfo queryDoctorByCId(CommentsVO commentsVO) {
        List<DoctorDO> queryDoctorByCId = commentsService.queryDoctorByCId(commentsVO);
        return getDataTable(queryDoctorByCId);
    }
    
    /**
    * @Description: 根据医生id进行查询其评论
    * @Param:
    * @return:  
    */
    @RequestMapping("/queryDoctorComment")
    public TableDataInfo queryDoctorComments(CommentsVO commentsVO) {
        System.err.println(commentsVO);
        PageUtils.startPage();
        List<CommentsDO> queryDoctorComments = commentsService.queryDoctorComments(commentsVO);
        return getDataTable(queryDoctorComments);
    }

    /**
     * @Description: 显示评论，条件查询不同医生的评论
     * @Param:
     * @return:
     */
    @RequestMapping("/queryComment")
    public TableDataInfo queryComments(CommentsVO commentsVO) {
        PageUtils.startPage();
        List<CommentsDO> queryComments = commentsService.queryComments(commentsVO);
        return getDataTable(queryComments);
    }

    /**
     * @Description: 删除评论
     * @Param:
     * @return:
     */
    @RequestMapping("/delComment")
    public AjaxResult updateComment(CommentsVO commentsVO) {
        Integer updateComment = commentsService.updateComment(commentsVO);
        return toAjax(updateComment);
    }

    /**
     * @Description: 根据医生id和用户id查询详情
     * @Param:
     * @return:
     */
    @RequestMapping("/queryUserRecords")
    public MedicalRecordDO queryUserRecords(CommentsVO commentsVO) {
        MedicalRecordDO queryUserRecords = commentsService.queryUserRecords(commentsVO);
        return queryUserRecords;
    }
}
